package com.amtf.datafile3.core.fil.render;

import com.amtf.datafile3.DataField;
import com.amtf.datafile3.DataFieldDefinition;
import com.amtf.datafile3.DataRecord;
import com.amtf.datafile3.DataRecordRender;
import com.amtf.datafile3.core.std.AbsDataRecordRender;

public class FilDataRecordRender extends AbsDataRecordRender {
	public FilDataRecordRender() {
	}

	public String rending(DataRecord value) {
		DataField[] fields = value.getFields();
		StringBuffer content = new StringBuffer();

		if (fields.length > 0) {
			for (int i = 0; i < fields.length; i++) {
				if (fields[i] != null) {
					content.append(fields[i].toString());
				} else {
					DataFieldDefinition def = fields[i].getDefinition();
					content.append(((FilDataFieldRender) def.getRender()).getFillString(def.getType().getTotalLength()));
				}
			}
		}

		return content.toString();
	}

	public String rendingTitle(String[] title) {
		StringBuffer content = new StringBuffer();

//		for (int i = 0; i < title.length; i++) {
//			if (title[i] != null) {
//				content.append(title[i]);
//			} else {
//			}
//		}

		return content.toString();
	}

	@Override
	public DataRecordRender clone() {
		FilDataRecordRender newObj = new FilDataRecordRender();
		return newObj;
	}
}
